package com.woniuxy.service.impl;

import com.woniuxy.entity.Mail;
import com.woniuxy.service.FanoutService;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: 马宇航
 * @Description: TODO
 * @DateTime: 22/10/20/0020 10:41
 * @Component: 成都蜗牛学苑
 **/
@Service
public class FanoutServiceImpl implements FanoutService {
    @Autowired
    RabbitTemplate rabbitTemplate;
    @Autowired
    RabbitTemplate.ConfirmCallback confirmCallback;
    @Override
    public void sendEmail(String fanoutExchange, Mail mail) {
        rabbitTemplate.setConfirmCallback(confirmCallback);
        rabbitTemplate.convertAndSend(fanoutExchange,"",mail,new CorrelationData(mail.getMailId()));
    }
}
